﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Handrise.CDCable.Mobile.GISControl;
using Handrise.CDCable.Mobile.Business;


namespace Handrise.CDCable.Mobile.UI
{
    public partial class FrmTaskPos : FrmBase
    
    {
        private Plan plan;
        public FrmTaskPos()
        {
            InitializeComponent();
            ttlbrhead.Text = ResourceImage.设备台账;
            ilstbcup.Images.Add(ResourceImage.空白);
            ilstbcup.Images.Add(ResourceImage.空白);
            ilstbcup.Images.Add(ResourceImage.返回01);
            ilstbcdown.Images.Add(ResourceImage.空白);
            ilstbcdown.Images.Add(ResourceImage.空白);
            ilstbcdown.Images.Add(ResourceImage.返回02);
            UGISmap.CacheStoragePath = AppLogic.GetLocalPath() + @"\mapcache";
            ibzoomout.UpImage = ResourceImage.缩小可点击;
            ibzoomout.DownImage = ResourceImage.缩小点击;
            ibzoomout.DisableImage = ResourceImage.缩小不可点击;
            Ibzoomin.UpImage = ResourceImage.放大可点击;
            Ibzoomin.DownImage = ResourceImage.放大点击;
            Ibzoomin.DisableImage = ResourceImage.放大不可点击;
            UGISmap.Getcatchmap(); 
            UGISmap.Scale = UGISmap.Scale / 15;
        }

        private void bcxunjian_OnButtonClick(object sender, int buttonIndex)
        {
            switch (buttonIndex)
            {
                case 0:
                      break;
                case 1:
                      break;
                case 2:
                      FormManage.GotoNext("FrmTaskDetail", new object[] { plan }, new object[] { plan }, true);
           
                    break;
                 
            }
        }

        private void ibzoomout_Click(object sender, EventArgs e)
        {

        }

        private void Ibzoomin_Click(object sender, EventArgs e)
        {

        }

        private void FrmTaskPos_Load(object sender, EventArgs e)
        {
            LoadData();
            Getpoint("");

        }
        private void Getpoint(string wheresql)
        {
            PlanDeviceService planDeviceService = new PlanDeviceService();      
            List<VPlanDevice> planDevices = new List<VPlanDevice>();
                  string sqlwhere =  " (PlanID='" + plan.PlanID.ToString() + "')";
                  planDevices = planDeviceService.GetsqlPlanDevice(sqlwhere);
                foreach (VPlanDevice pdevice in planDevices)
                {
                    {
                        if (!(UGISmap.ListPoint.Exists(delegate(PDGPS p) { return p.DeviceCode == pdevice.DeviceCode; })))
                        {
                            PDGPS PDGPS = new PDGPS();
                            PDGPS.DeviceGPSID = pdevice.DeviceID;
                            PDGPS.DeviceCode = pdevice.DeviceCode;
                            PDGPS.DeviceType = pdevice.DeviceType;
                            PDGPS.LocalGPSInfo = pdevice.LocalGPSInfo;
                            PDGPS.GPSInfo = pdevice.GPSInfo;
                            PDGPS.Devicename = pdevice.DeviceName;
                            UGISmap.ListPoint.Add(PDGPS);
                        }
                    }
                }
              //  UGISmap.ShowDeviceName = true;
                UGISmap.changepoint();
            }

        private void LoadData()
        {
            plan = (Plan)Parameter[0];     
        }

        private void Ibzoomin_Click_1(object sender, EventArgs e)
        {
            UGISmap.Scale = UGISmap.Scale - UGISmap.Scale / 5;
            UGISmap.showlayer();
        }

        private void ibzoomout_Click_1(object sender, EventArgs e)
        {
            UGISmap.Scale = UGISmap.Scale + UGISmap.Scale / 5;
            UGISmap.showlayer();
        }

        private void FrmTaskPos_Closed(object sender, EventArgs e)
        {
            UGISmap.closecatch();
        }


    }
}